<!DOCTYPE html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <script src="./js/vue.js"></script>
    <script src="./js/vue-router.js"></script>
</head>

<body>
    <div id="app">
        <router-link to="/a">跳转至组件A</router-link>
        <router-link to="/b">跳转至组件B</router-link>
        <router-view></router-view>

    </div>
    <script>
        // 1\定义组件
        var comA = {
            template:`
            <div>这里是组件A</div>
            `
        }
        var comB = {
            template:`
            <div>这里是组件B</div>
            `
        }
        // 2、定义路由
        var router = new VueRouter({
            routes:[
                {path:"/a",component:comA},
                {path:"/b",component:comB},
            ]
        
        })
     
        var vm = new Vue({
            el: '#app',
            data: {},
            methods: {},
            router
        })
    </script>
</body>

</html>